package com.acane.instagram.mapper;

import com.acane.instagram.pojo.User;
import com.acane.instagram.pojo.dto.FollowDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface FollowMapper extends BaseMapper<FollowDTO> {

    @Select("select * from follows where following_id = #{userId} order by update_time desc")
    List<FollowDTO> getFollowHistory(@Param("userId") String userId);

    @Select("select * from user where id in (select follower_id from follows where following_id = #{userId} and status = 1)")
    List<User> getFollowerList(@Param("userId") String userId);

    @Select("select * from user where id in (select following_id from follows where follower_id = #{userId} and status = 1)")
    List<User> getFollowingList(@Param("userId") String userId);
}
